﻿/*=================================================================
* 版权信息：Copyright (C) 2005-2011 捷点科技 All Rights Reserved.
* 文件名称：CNVP_SEOInfo.cs
* 创建标识：曾乃强 15158756652 2011-03-22 09:03:17
* 修改标识：
* 功能描述：
===================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using CNVP.Framework.Helper;
using CNVP.Config;

namespace CNVP.JShop.DAL
{
    /// <summary>
    /// 对*CNVP_SEOInfo*操作数据库(针对SQL Server)的实现
    /// </summary>
    public class CNVP_SEOInfo
    {
       private string Prefix = DBConfig.Prefix;
        #region DAL
        public int Insert(Model.CNVP_SEOInfo obj)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("insert into  " + Prefix + "SEOInfo ([OriginTitle],[OriginKey],[OriginDescription])");
            sql.Append("values(@OriginTitle,@OriginKey,@OriginDescription)");
            sql.Append(";SELECT @@IDENTITY");
            SqlParameter[] pra = {
                            new SqlParameter("@OriginTitle",obj.OriginTitle),
							new SqlParameter("@OriginKey",obj.OriginKey),
							new SqlParameter("@OriginDescription",obj.OriginDescription)
                                 };
            return Convert.ToInt32(DbHelper.ExecuteScalar(sql.ToString(), pra));
        }

        public int Update(Model.CNVP_SEOInfo obj)
        {
             StringBuilder sql = new StringBuilder();
             sql.Append("update " + Prefix + "SEOInfo set [OriginTitle] = @OriginTitle,[OriginKey] = @OriginKey,[OriginDescription] = @OriginDescription where [ID] = @ID");

            SqlParameter[] pra = { 
                            new SqlParameter("@ID",obj.ID),
							new SqlParameter("@OriginTitle",obj.OriginTitle),
							new SqlParameter("@OriginKey",obj.OriginKey),
							new SqlParameter("@OriginDescription",obj.OriginDescription)
                                };
             return DbHelper.ExecuteNonQuery(sql.ToString(),pra);
        }

        public int Delete(Model.CNVP_SEOInfo obj)
        {
           StringBuilder sql = new StringBuilder();
           sql.Append("delete from " + Prefix + "SEOInfo where [ID] = @ID");
           SqlParameter[] pra = {
                                new SqlParameter("@ID",obj.ID)
						
                                };
           return DbHelper.ExecuteNonQuery(sql.ToString(),pra);
        }

        public Model.CNVP_SEOInfo LoadById(int ID)
        {
            
            StringBuilder sql = new StringBuilder();
            sql.Append("select [OriginTitle],[OriginKey],[OriginDescription] from " + Prefix + "SEOInfo");
            sql.Append(" where [ID] = @ID");
            SqlParameter[] pra = {
                                 new SqlParameter("@ID",ID)
						
                                    };
            DataTable DT = DbHelper.ExecuteTable(sql.ToString(),pra);
            Model.CNVP_SEOInfo cnvp_seoinfo = new Model.CNVP_SEOInfo();
            if (DT != null && DT.Rows.Count > 0)
            {
                DataRow dr = DT.Rows[0];
                cnvp_seoinfo.OriginTitle = dr["OriginTitle"] is DBNull ? String.Empty : (string)dr["OriginTitle"];
                cnvp_seoinfo.OriginKey = dr["OriginKey"] is DBNull ? String.Empty : (string)dr["OriginKey"];
                cnvp_seoinfo.OriginDescription = dr["OriginDescription"] is DBNull ? String.Empty : (string)dr["OriginDescription"];
            }
            return cnvp_seoinfo;
        }

        #endregion
    }
}

